package com.springboot.study.tests.ioc;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: guodong
 * @Date: 2021/10/9 10:04
 * @Version: 1.0
 * @Description:
 */
@Configuration
public class IocConfig {

    @Bean
    @ConditionalOnMissingBean(TobyA.class)
    public TobyA tobyA(){
        return new TobyA();
    }

    @Bean
    @ConditionalOnBean(TobyA.class)
    @ConditionalOnClass(TobyA.class)
    public TobyB tobyB(){
        return new TobyB();
    }

}
